<extend name="Public:base"/>
<block name="content">
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-info">
            <div class="panel-heading">增加分类</div>
            <div class="panel-body">
                <div class="row">
                    <div class="col-lg-12">
                        <form action="{$action}" class="form-horizontal" method="post">
                            <div class="form-group">
                                <label for="sc_pid" class="col-sm-2 control-label">父分类：</label>
                                <div class="col-sm-10">
                                    <select class="form-control" name="sc_pid" id="sc_pid">
                                        <option value="">--请选择父分类--</option>
                                        <option value="1">顶级分类</option>
                                        <volist name="topCat" id="vo">
                                        <option value="{$vo.sc_id}">{$vo.sc_name}</option>
                                        </volist>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="sc_name" class="col-sm-2 control-label">分类名称：</label>

                                <div class="col-sm-10">
                                    <input type="text" class="form-control" name="sc_name" id="sc_name" placeholder="分类名称" value="{$cat.sc_name}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="sc_ename" class="col-sm-2 control-label">分类别名：</label>

                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="sc_ename" name="sc_ename" placeholder="分类别名" value="{$cat.sc_ename}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">分类状态：</label>

                                <div class="col-sm-10">
                                    <label class="radio-inline">
                                        <input type="radio" name="sc_status" value="1" checked> 启用
                                    </label>
                                    <label class="radio-inline ">
                                        <input type="radio" name="sc_status" value="0"> 禁用
                                    </label>

                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <input type="hidden" name="sc_id" value="{$cat.sc_id}"/>
                                    <button type="submit" class="btn btn-default">添加</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    ThinkPHP.setValue('sc_pid', "{$pid}");
    ThinkPHP.setValue('sc_status', "{$cat.sc_status}");
    $(function(){
        $('input[name=sc_name]').on('blur',function(){
            var name =  $(this).val();
            if(!name) return false;
            $.post(ThinkPHP.U('Category/pinyin'), {name : $(this).val()}, function(data, status){
                if(data.status) $('input[name=sc_ename]').val(data.info);
            }, 'json');
        });
    });
</script>
    </block>